import java.util.Scanner;

public class Min {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();
        scan.nextLine();
        for(int i = 0;i < n;i++) {
            char[] arr = scan.nextLine().toCharArray();
            System.out.println(check(arr) ? "YES" : "NO");
        }
        scan.close();
    }
    public static boolean check(char[] arr) {
        if(arr.length == 0) {
            return false;
        }
        int r = arr.length-1;
        int l = 0;
        while(arr[r] == 'l' || arr[r] == 'q' || arr[r] == 'b') {
            r--;
        }
        while(l != r && arr[l] == arr[r]) {
            r--;
            if(l!=r) {
                l++;
            }
        }
        return l == r;
    }
}
